<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%--
  Created by IntelliJ IDEA.
  User: xwj32
  Date: 2023-05-24
  Time: 22:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <jsp:include page="include/mangerheadtag.jsp"/>
  <link rel="stylesheet" href="https://cdn.staticfile.org/font-awesome/5.15.3/css/all.min.css">
  <link rel="stylesheet" href="https://cdn.staticfile.org/bootstrap/5.0.1/css/bootstrap.min.css">
  <title>医生主页预约</title>
  <style>
    body {
      background-color: #f0f2f5;
    }
    .card {
      border-radius: 10px;
      margin: 20px;
      box-shadow: 0 0 20px rgba(0,0,0,0.1);
    }
    .card-header {
      border-radius: 10px 10px 0 0;
      background-color: #007bff;
      color: #fff;
    }
    .form-label {
      font-weight: 500;
    }
    .form-input {
      padding: .375rem .75rem;
      line-height: 1.5;
      background-color: #fff;
      border: 1px solid #ced4da;
      border-radius: .3rem;
    }
    .form-text {
      font-size: 80%;
    }
    .btn-appointment {
      background-color: #007bff;
      border-color: #007bff;
    }
    .btn-appointment:hover {
      background-color: #0056b3;
      border-color: #0056b3;
    }
    .btn-full {
      background-color: #ff5050;
      border-color: #ff5050;
    }
    .btn-full:hover {
      background-color: #e00000;
      border-color: #e00000;
    }
  </style>
</head>
<body>
<jsp:include page="include/head.jsp"/>
<jsp:include page="include/menu.jsp"/>
<div class="container mt-5" style="margin-top: 100px;margin-left: 240px">
  <div class="card" style="margin-top: 50px">
    <div class="card-header">
      <h4 class="mb-0">医生主页预约</h4>
    </div>
    <div class="card-body">
      <div class="row mb-3">
        <label for="input-name" class="col-sm-2 col-form-label form-label">医生姓名</label>
        <div class="col-sm-4">
          <input type="text" class="form-control form-input" id="input-name" value="${requestScope.appointed_doctor.dname}" readonly>
        </div>
        <label for="input-title" class="col-sm-2 col-form-label form-label">职称</label>
        <div class="col-sm-4">
          <input type="text" class="form-control form-input" id="input-title" value="${requestScope.appointed_doctor.career}" readonly>
        </div>
      </div>
      <div class="row mb-3">
        <label for="input-expertise" class="col-sm-2 col-form-label form-label">擅长</label>
        <div class="col-sm-10">
          <input type="text" class="form-control form-input" id="input-expertise" value="${requestScope.appointed_doctor.ability}" readonly>
        </div>
      </div>
      <div class="row mb-3">
        <label for="input-intro" class="col-sm-2 col-form-label form-label">介绍</label>
        <div class="col-sm-10">
          <textarea class="form-control form-input" id="input-intro" rows="3" readonly>${requestScope.appointed_doctor.description}</textarea>
        </div>
      </div>
      <div class="row mb-3">
        <label class="col-sm-2 col-form-label form-label">排班信息</label>
        <div class="col-sm-10">
          <div class="row mb-2">
            <div class="col-sm-2">
              <span class="form-text">时间</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">星期</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">上/下午</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">科室</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">院区</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">余号/总号</span>
            </div>
          </div>
          <div class="row mb-2">
            <div class="col-sm-2">
              <span class="form-text">${requestScope.doctorSchedule.doctor_name}</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">${requestScope.doctorSchedule.day_of_week}</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">${requestScope.doctorSchedule.ampm}</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">${requestScope.doctorSchedule.department}</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">A院区</span>
            </div>
            <div class="col-sm-2">
              <span class="form-text">${requestScope.doctorSchedule.appointment_count-requestScope.doctorSchedule.booked_count}/${requestScope.doctorSchedule.appointment_count}</span>
            </div>
          </div>
        </div>
      </div>
      <div class="row mb-3">
        <label for="input-fee" class="col-sm-2 col-form-label form-label">诊费</label>
        <div class="col-sm-4">
          <input type="text" class="form-control form-input" id="input-fee" value="${requestScope.appointed_doctor.fee}元" readonly>
        </div>
      </div>
      <div class="row mb-3">
        <div class="col-sm-6 offset-sm-2">
           <form method="get" action="<%=request.getContextPath()%>/ChooseDoctorServlet" >
             <input type="hidden" name="action" value="insertRecord">
             <input type="hidden" name="dname" value="${requestScope.appointed_doctor.dname}">
             <input class="btn btn-appointment w-100" type="submit" value="${requestScope.doctorSchedule.status}">
          </form>
        </div>
      </div>
    </div>
  </div>
</div>
<script src="https://cdn.staticfile.org/bootstrap/5.0.1/js/bootstrap.bundle.min.js"></script>
<script>
  var btnAppointment = document.querySelector('.btn-appointment');
  var btnFull = document.querySelector('.btn-full');
  var remain = 2; //余号

  btnAppointment.addEventListener('click', function () {
    if (remain > 0) {
      remain--;
      btnAppointment.textContent = '已预约 (' + remain + '/4)';
      if (remain === 0) {
        btnAppointment.classList.add('d-none');
        btnFull.classList.remove('d-none');
      }
    } else {
      alert('预约人数已满，不可预约');
    }
  });
</script>
</body>
</html>
